package com.wyz.rabbitmqdomo.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectRabbitMqConfig {

    @Bean
    public DirectExchange getDirectExchange(){
        return new DirectExchange("direct_order_exchange", true, false);
    }

    @Bean
    public Queue getDirectSmsQueue(){
        return new Queue("sms.direct.queue", true);
    }

    @Bean
    public Queue getDirectEmailQueue(){
        return new Queue("email.direct.queue", true);
    }

    @Bean
    public Queue getDirectDxQueue(){
        return new Queue("dx.direct.queue", true);
    }

    @Bean
    public Binding getDirectSmsBinding(){
        return BindingBuilder.bind(getDirectSmsQueue()).to(getDirectExchange()).with("sms");
    }

    @Bean
    public Binding getDirectEmailBinding(){
        return BindingBuilder.bind(getDirectEmailQueue()).to(getDirectExchange()).with("email");
    }

    @Bean
    public Binding getDirectDxBinding(){
        return BindingBuilder.bind(getDirectDxQueue()).to(getDirectExchange()).with("dx");
    }
}
